<?php
/**
 * This is AreasUser model file. 
 *
 * @copyright     Copyright 2008-2010, LilCake.net
 * @link          http://lilcake.net LilCake.net
 * @package       lil
 * @subpackage    lil.models
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
/**
 * AreasUser class
 *
 * @uses          LilAppModel
 * @package       lil
 * @subpackage    lil.models
 */
class AreasUser extends LilAppModel {
/**
 * name property
 *
 * @var string 'AreasUser'
 * @access public
 */
	public $name = 'AreasUser';
/**
 * __construct method
 *
 * @param mixed $id
 * @param mixed $table
 * @param mixed $ds
 * @return void
 */
	public function __construct($id = false, $table = null, $ds = null)	{
		$this->useTable = Configure::read('Lil.areasUsersTable');
		parent::__construct($id, $table, $ds);
	}
/**
 * isAllowed method
 *
 * @param mixed $user_id
 * @param mixed $area_id
 * @return bool
 */
	public function isAllowed($user_id, $area_id) {
		$assoc = Configure::read('Lil.userAssociation');
		return
			$this->hasAny(array(
				$assoc['foreignKey']            => $user_id,
				$assoc['associationForeignKey'] => $area_id
			));
	}
}